package com.ferdict;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.net.URLEncoder;

import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

public class VoteTask implements Runnable {
	private static final String TAG = VoteTask.class.getName();

//	@Override
	public void run() {

	}

	private void doApprove(long outfitId) {
		HttpURLConnection httpCxn = null;
		Log.d(TAG, String.format("Aproving outfit(id=%d).", outfitId));

//		try {
//			if (Thread.interrupted()) {
//				throw new InterruptedException();
//			}
//			String q = URLEncoder.encode("1", "UTF-8");
//			URL url = new URL("http://localhost/outfits.json/");
//			httpCxn = (HttpURLConnection) url.openConnection();
//			httpCxn.setConnectTimeout(1000);
//			httpCxn.setReadTimeout(1000);
//			httpCxn.setRequestMethod("PUT");
//			// httpCxn.addRequestProperty(field, newValue);
//			httpCxn.setDoInput(true);
//
//			httpCxn.connect();
//			if (Thread.interrupted()) {
//				throw new InterruptedException();
//			}
//
//			BufferedReader reader = new BufferedReader(new InputStreamReader(
//					httpCxn.getInputStream(), "UTF-8"));
//			String payload = reader.readLine();
//			reader.close();
//
//			JSONObject json = new JSONObject(payload);
//			String result = json.getJSONObject("responseData").getString(
//					"fieldName");
//		} catch (InterruptedException e) {
//			Log.e(TAG, InterruptedException.class.getName(), e);
//		} catch (UnsupportedEncodingException e) {
//			Log.e(TAG, InterruptedException.class.getName(), e);
//		} catch (MalformedURLException e) {
//			Log.e(TAG, InterruptedException.class.getName(), e);
//		} catch (ProtocolException e) {
//			Log.e(TAG, InterruptedException.class.getName(), e);
//		} catch (IOException e) {
//			Log.e(TAG, InterruptedException.class.getName(), e);
//		} catch (JSONException e) {
//			Log.e(TAG, InterruptedException.class.getName(), e);
//		}

	}
}
